'use strict';

angular.module('app').controller('positionCtrl', ['$scope', '$http', '$state', '$q', function ($scope, $http, $state, $q) {

    $scope.isLogin = false;

    function getPosition() {
        var def = $q.defer();
        $http.get('/data/position.json?id=' + $state.params.id).success(function (res) {
            $scope.position = res;
            def.resolve(res);
        }).error(function (err) {
            def.reject(err);
        });
        return def.promise;
    }

    function getCompany(id) {
        $http.get('/data/company.json?id=' + id).success(function (res) {
            $scope.company = res;
        })
    }

    //解决回调地域
    getPosition().then(function (obj) {
        //console.log(obj)
        getCompany(obj.companyId);
    }, function () {

    });

}]);